#include"LogStream.h"
#include"Logger.h"
#include"TaskMgr.h"
#include<string>
#include"FileMgr.h"
#include"TTime.h"
#include<thread>
#include"Task.h"
using namespace tmms::base;

std::thread t;
void TestLog(){
    t = std::thread([](){
        while(true){
            LOG_TRACE << "test LOG_TRACE !!! Now:"<<TTime::NowMS();
            LOG_DEBUG << "test LOG_DEBUG !!! Now:"<<TTime::NowMS();
            std::this_thread::sleep_for(std::chrono::milliseconds(500));
        }
        
    });
}


int main(){

    FileLogPtr log = kFileMgr->GetFIleLog("test.log");
    log->SetRotate(RotateType::kRotateMinute);
    g_loger = new Logger(log);
    g_loger->SetLogLevel(kTrace);
    TaskPtr task = std::make_shared<Task>([](const TaskPtr &task){
        kFileMgr->OnCheck();
        task->Restart();
    },1000);
    sTaskMgr->Add(task);
    TestLog();
    while(1){
        sTaskMgr->onWork();
        std::this_thread::sleep_for(std::chrono::milliseconds(50));
    }
    
    return 0;
}